﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using YArchitech.Controls;
using YArchitech.LIB;

namespace YJKRoom.SpaceRoomNameCreation
{
	public partial class SpaceRoomNameCreationForm : System.Windows.Forms.Form
	{
		public SpaceRoomNameCreationForm(List<string> paraNames, List<ModelTextType> textNoteTypes)
		{
			this.InitializeComponent();
			this.lstRoomParaNames.Items.Clear();
			foreach (string item in paraNames)
			{
				this.lstRoomParaNames.Items.Add(item);
			}
			this.cmbFont.Items.Clear();
			foreach (ModelTextType modelTextType in textNoteTypes)
			{
				this.cmbFont.Items.Add(modelTextType.Name);
			}
			if (this.cmbFont.Items.Count > 0)
			{
				this.cmbFont.SelectedIndex = 0;
			}
		}

		private void SpaceRoomNameCreationForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
		}

		private void lstRoomParaNames_DoubleClick(object sender, EventArgs e)
		{
			string text = ((ListBox)sender).SelectedItem.ToString();
			if (this.tbRoomName.TextLength != 0)
			{
				this.tbRoomName.AppendText("\r\n");
			}
			text = "[" + text + "]";
			this.tbRoomName.AppendText(text);
		}

		public int GetSelIndexFontType()
		{
			return this.cmbFont.SelectedIndex;
		}

		public List<string> GetSelRoomParaNames()
		{
			string[] lines = this.tbRoomName.Lines;
			List<string> list = new List<string>();
			foreach (string item in lines)
			{
				list.Add(item);
			}
			return list;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			if (this.tbRoomName.TextLength < 1)
			{
				YJKMessageBox.Show("三维房间字符串不能为空。");
				base.DialogResult = DialogResult.None;
			}
		}

		private void SpaceRoomNameCreationForm_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
		}
	}
}
